#include "material.h"
#include "utils.h"

Material::Material(QObject *parent)
    : QObject{parent}
{}


Material* Material::FromJson(QJsonObject &data){
    auto info = new Material();
    info->CreateTime = GetString(data, "createTime");
    info->DateCount = GetInt(data, "dateCount");
    info->DateUnit = GetInt(data, "dateUnit");
    info->HasPart = GetInt(data, "hasPart");
    info->HasWarn = GetInt(data, "hasWarn");
    info->Id = GetInt(data, "id");
    info->Name = GetString(data, "name");
    info->OperationType = GetInt(data, "operationType");
    info->PartCount = GetInt(data, "partCount");
    info->PartUnit = GetInt(data, "partUnit");
    info->Remark = GetString(data, "remark");
    info->SaveType = GetInt(data, "saveType");
    info->ShortName = GetString(data, "shortName");
    info->Status = GetInt(data, "stauts");
    info->TypeName = GetString(data, "typeName");
    info->Unit = GetInt(data, "unit");
    info->WarnCount = GetInt(data, "warnCount");
    info->WarnUnit = GetInt(data, "warnUnit");

    return info;
}

